package com.qtt.app.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.qtt.app.controller"))
                .paths(PathSelectors.any()).build();
    }
    //注意修改.apis()中的包名！

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("cmall App系统")
                .description("由于分工、开发进度和新增功能等原因，app系统的后端开发需要在最初设计的数据表基础上新增字段，并新增了机构表、关注表、观看历史表、浏览记录表、优惠券表等，且许多接口都需要重新实现")
//                .contact(new Contact("huangmx","","1572717834@qq.com"))
                .version("1.2.0")
                .build();
    }

}

//http://localhost:9000/swagger-ui.html
